package org.mozhu.simple.rpc.server.network;

import java.nio.ByteBuffer;
import java.util.Optional;

public abstract class RequestOrResponse {

    private Optional<Short> requestId;

    public RequestOrResponse(Optional<Short> requestId) {
        this.requestId = requestId;
    }

    public Optional<Short> getRequestId() {
        return requestId;
    }

    public abstract int sizeInBytes();

    public abstract void writeTo(ByteBuffer byteBuffer);

    public abstract void handleError(Throwable t, RequestChannel requestChannel, RequestChannel.Request request);

}
